package com.sjx.onelinecord.ui

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.sjx.onelinecord.R
import kotlinx.android.synthetic.main.activity_permission_dispatcher_aty.*
import permissions.dispatcher.NeedsPermission
import permissions.dispatcher.RuntimePermissions

@RuntimePermissions
class PermissionDispatcherAty : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_permission_dispatcher_aty)
        make_call.setOnClickListener {
            onCallPhone()
        }
    }

    @NeedsPermission(android.Manifest.permission.CALL_PHONE)
    fun onCallPhone(): Unit {
        try {
            val intent = Intent(Intent.ACTION_CALL)
            intent.data = (Uri.parse("tel:10086"))
            startActivity(intent)
        } catch (e: SecurityException) {
            e.printStackTrace()
        }
    }


}